package shop

import (
	"day12_16_shop/internal/api/request"
	"day12_16_shop/internal/models/service"
	"github.com/gin-gonic/gin"
	"net/http"
)

func ShopList(c *gin.Context) {
	var json *request.ShopListRequest
	if err := c.ShouldBindJSON(&json); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	shop, s := service.ListShop(json)
	if s != "" {
		c.JSON(http.StatusBadRequest, gin.H{
			"message": s,
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"message": "展示成功",
		"data":    shop,
	})

}
